package jess;

import java.lang.reflect.Method;
import java.util.Comparator;

/**
 * A Comparator that can be used to sort an array of
 * java.lang.reflect.Method objects.
 * <P>
 * (C) 2006 Sandia National Laboratories<br>
 */

class MethodNameComparator implements Comparator {
    private static Comparator s_instance = new MethodNameComparator();

    public static Comparator getInstance() {
        return s_instance;
    }

    public int compare(Object o1, Object o2) {
        if (o1 instanceof Method)
            o1 = ((Method) o1).getName();
        if (o2 instanceof Method)
            o2 = ((Method) o2).getName();
        return ((String) o1).compareTo((String) o2);
    }
}
